package com.huasan.www.demon.util;

import java.util.ResourceBundle;

import javax.annotation.PostConstruct;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.BeansException;
import org.springframework.context.ApplicationContext;
import org.springframework.context.ApplicationContextAware;

import com.huasan.www.demon.rest.util.Constants;

public class ConfigUtil implements ApplicationContextAware{

	private static ApplicationContext applicationContext = null;

    private static Logger logger = LoggerFactory.getLogger(ConfigUtil.class);
    
    private final String configPath = "resource.config";
    
    @PostConstruct
    public void init(){
    	logger.debug("init parameters..............");
    	setRoot();
    }
	
	@Override
	public void setApplicationContext(ApplicationContext applicationContext)
			throws BeansException {
		// TODO Auto-generated method stub
		this.applicationContext = applicationContext;
	}
	
	public boolean setRoot(){
		ResourceBundle bundle = ResourceBundle.getBundle(configPath);
		String filters = bundle.getString("rest.filter.classes");
		if (filters!=null && !"".equals(filters))
			Constants.FILTER_CLASSES = filters.split(",");
		return true;
	}

}
